using System;

namespace Crawler
{
	/// <summary>
	/// Understands the resource.
	/// </summary>
	public class ResourceReference : IResourceReference
	{
		IResourcePath path;

		public static IResourceReference NULL_REFERENCE = NullReference.NULL_REFERENCE ;
	
		public ResourceReference(string path) {
			this.path = new ResourcePath(path);
		}

		public ResourceReference(IResourcePath path)
		{
			this.path = path;	
		}

		public IResourcePath Path {
			get{return this.path;}
		}

		public override bool Equals(object obj) {
			bool e = ((ResourceReference)obj).Path.ToString()   == this.Path.ToString() ;
			return	e;
		}

		public virtual String StreamDump()
		{
			return this.Path.ToString();
		}

		public virtual void SetContent(string content)
		{
			
		}


		/// <summary>
		/// understands a null resource reference 
		/// </summary>
		private class NullReference : IResourceReference {
			
			public static IResourceReference NULL_REFERENCE = new NullReference();

			private NullReference() {} 
			
			#region IResourceReference Members

			public IResourcePath Path {
				get {
					return ResourcePath.NO_PATH  ;
				}
			}

			public bool Equals(object obj) {
				return false;
			}

			public String StreamDump() {
				return "";
			}

			public void SetContent(string content)
			{
			}

			#endregion
		}
	}
}
